package com.aabbc.artemis.producer;

import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

/**
 * Producer
 *
 * @author: <a href="mailto:chenfenghai@oristartech.com">chenfenghai</a>
 * @version: 1.0
 * @date: 2019-11-27 15:58
 */
@Component
public class OrderProducer {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    public void send(final String message) {
        Destination destination = new ActiveMQQueue("mytest.queue");
        jmsMessagingTemplate.convertAndSend(destination, message + " from queue");
    }

    @JmsListener(destination="out.queue")
    public void consumerMessage(String text){
        System.out.println("从out.queue队列收到的回复信息为: "+text);
    }
}
